﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using System.Data.SqlClient;
using System.Data;
using WFNetLib.ADO;

namespace DAL
{
    public class unit_logDal
    {
        public int AddUnitLog(unit_logData unit_log)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into unit_log(");
            strSql.Append("unit_number,unit_shelf_number,query_user_id,query_time,result_flag)");
            strSql.Append(" values (");
            strSql.Append("@unit_number,@unit_shelf_number,@query_user_id,@query_time,@result_flag)");
            //strSql.Append(";select @@IDENTITY ");
            SqlParameter[] parameters = {
                    new SqlParameter("@unit_number", SqlDbType.VarChar,10),
                    new SqlParameter("@unit_shelf_number", SqlDbType.VarChar,20),                    
                    new SqlParameter("@query_user_id", SqlDbType.Int,4),
                    new SqlParameter("@query_time", SqlDbType.DateTime),
                    new SqlParameter("@result_flag", SqlDbType.Bit)
                                        };
            parameters[0].Value = unit_log.unit_number;
            parameters[1].Value = unit_log.unit_shelf_number;
            parameters[2].Value = unit_log.query_user_id;
            parameters[3].Value = unit_log.query_time;
            parameters[4].Value = unit_log.result_flag;
            object obj = SQLServerOP.ScalarSQL(strSql.ToString(), parameters);            
            if (obj == null)
            {
                return 1;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
    }
}
